<?php

use Illuminate\Database\Seeder;
use App\Models\User;
use Faker\Generator as Faker;
use App\Models\Package;



class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run(Faker $faker)
    {
        // 套餐分类
        $packate = Package::get()->pluck('id')->toArray();

        $users = factory(User::class)->times(100)->make()->each(function($query) use ($faker , $packate){
            $query->package_id = $faker->randomElement($packate);
        });

        // 让隐藏字段可见，并将数据集合转换为数组
        $user_array = $users->makeVisible(['password','remember_token'])->toArray();

        User::insert($user_array);

        $user = User::find(1);
        $user->name = '345111458';
        $user->account = '345111458';
        $user->email = '345111458@qq.com';
        $user->save();


    }
}
